<!DOCTYPE html>
<html>
<head>
	<title>react-双向数据绑定</title>
    <meta charset="UTF-8" />
	<script src='../node_modules/react/umd/react.development.js'></script>
	<script src='../node_modules/react-dom/umd/react-dom.development.js'></script>
    <script src='../node_modules/babel-standalone/babel.min.js'></script>
    <script>
    /**
      约束性与非约束性
        1.约束性收到react管理，state.xxx，同时state也用于双向数据绑定
        2.非约束性不受react管理，相当于原生js，例如 defaultValue ?
    */
    </script>
</head>
<body>
    <div id="my"></div>
    <script type="text/babel">
    class Hello extends React.Component{
        constructor(){
            super();
            this.state = {
                value:'abc'
            };
        };
        handleChange(e){
            this.setState({
                value:e.target.value 
            })
        };
        
        render(){ 
            return (
                <div>
                    <p>
                        <input type="text" defaultValue="123"/>
                    </p>
                    <p>
                        <input type="text" value={this.state.value} 
                        onChange={(e)=>this.handleChange(e)}/>
                        <span>{this.state.value}</span>
                    </p>
                </div>
                )
        }
    };
    
     ReactDOM.render(
          <Hello/>,
        document.getElementById('my')
    )
    </script>
</body>
</html>